package gui;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;

public class AbaPagamento extends JPanel {

	private JLabel labelTexto1;
	private JLabel labelSaldo;
	private JLabel labelTexto2;
	private JLabel labelTotalCompra;
	private JLabel labelTexto3;
	private JLabel labelSaldoFinal;
	private JButton buttonConcluir;
	private JButton buttonVoltar;

	private JPanel painelSaldo;
	private JPanel painelTotalCompra;
	private JPanel painelSaldoFinal;
	private JPanel painelBotoes;

	public AbaPagamento() {
		this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));

		labelTexto1 = new JLabel("Seu saldo atual: R$");
		labelSaldo = new JLabel();
		labelTexto2 = new JLabel("Valor da compra: R$");
		labelTotalCompra = new JLabel();
		labelTexto3 = new JLabel("Seu saldo final: R$");
		labelSaldoFinal = new JLabel();
		buttonConcluir = new JButton("Concluir");
		buttonConcluir.addActionListener(new Ouvinte());
		buttonVoltar = new JButton("Voltar..");
		buttonVoltar.addActionListener(new Ouvinte());

		painelSaldo = new JPanel();
		painelSaldo.add(labelTexto1);
		painelSaldo.add(labelSaldo);

		painelTotalCompra = new JPanel();
		painelTotalCompra.add(labelTexto2);
		painelTotalCompra.add(labelTotalCompra);

		painelSaldoFinal = new JPanel();
		painelSaldoFinal.add(labelTexto3);
		painelSaldoFinal.add(labelSaldoFinal);

		painelBotoes = new JPanel();
		painelBotoes.add(buttonConcluir);
		painelBotoes.add(buttonVoltar);

		this.add(painelSaldo);
		this.add(painelTotalCompra);
		this.add(painelSaldoFinal);
		this.add(painelBotoes);

	}

	class Ouvinte implements ActionListener {

		public void actionPerformed(ActionEvent arg0) {
			// TODO Auto-generated method stub

			if (arg0.getSource() == buttonConcluir) {
				// olhar o q fazer
			} else { // aviso veio de buttonVoltar
				// some com a aba pagamento e exibe a aba carrinho
				Principal.tabManager.setEnabledAt("Pagamento", false);
				Principal.tabManager.setEnabledAt("Carrinho", true);
				Principal.tabManager.setSelectedTab("Carrinho");
			}
		}

	}

}
